//
//  BaseTableViewController.swift
//  weibo_swift
//
//  Created by dulinlong on 15/6/24.
//  Copyright © 2015年 sheji_56. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController ,VistorViewDelegate{
    
    /// 用户登录标志
    var userLogin: Bool = sharedUserAccount != nil
    //访客视图界面
    var vistorView:VistorView?
    
    override func loadView() {
        
        userLogin ? super.loadView() : setupVistorView()
    }
   
    ///  加载访客视图
    func setupVistorView(){
        vistorView = VistorView()
        view = vistorView
        vistorView?.delegate = self
        
        
        //设置navigationBar
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registerButtonClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginButtonClick")
    }
    
    func registerButtonClick(){
        print("注册")
    }
    func loginButtonClick(){
        
        print("登录")
        
        let oAuth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oAuth)
        
        presentViewController(nav, animated: true, completion: nil)
    }
}
